import java.util.Scanner;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2023/3/25 15:50
 * 统计每个月兔子的总数
 * 字符串通配符
 */
public class Day18 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();
        str1 = str1.toLowerCase();
        str2 = str2.toLowerCase();
        System.out.println(stringCompD(str1,str2,0,0));
    }

    //-------------------------------------------------
    //完全AC===---
    //    import java.io.*;
//import java.util.*;
//    public class Main {
//
//        public static void main(String[] args) throws IOException {
//            BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
//            String value;
//            while ((value = bf.readLine()) != null) {
//                String target = bf.readLine();
//                value = value.toLowerCase(Locale.ROOT);
//                target = target.toLowerCase(Locale.ROOT);
//                String regx = value.replaceAll("\\*{2,}", "\\*");
//                regx = regx.replaceAll("\\?", "[0-9a-z]{1}");
//                regx = regx.replaceAll("\\*", "[0-9a-z]{0,}");
//                System.out.println(target.matches(regx));
//            }
//        }
//
//    }
    //-------------------------------------------------
    //递归
    public static boolean stringCompD(String str1 ,String str2 ,int indexOfCh1 ,int indexOfCh2){ //64

        if ((indexOfCh1 == str1.length() && indexOfCh2 == str2.length())){
            return true;
        }
        if (indexOfCh1 == str1.length() || indexOfCh2 == str2.length()){
            return false;
        }
        //优先处理
        if (str1.charAt(indexOfCh1)==str2.charAt(indexOfCh2)){
            return stringCompD(str1, str2, indexOfCh1 + 1, indexOfCh2+1);
        }
        //对*的特殊处理
        if (str1.charAt(indexOfCh1) == '*' && indexOfCh1 + 1 != str1.length() && str1.charAt(indexOfCh1 + 1) == '*') {
            return stringCompD(str1, str2, indexOfCh1 + 1, indexOfCh2);
        }
        //对？ / * 的常规处理
        if (str1.charAt(indexOfCh1) == '?'
                && ((str2.charAt(indexOfCh2) >= '0' && str2.charAt(indexOfCh2) <= '9')
                ||(str2.charAt(indexOfCh2) >= 'a' && str2.charAt(indexOfCh2) <= 'z'))){
            return stringCompD(str1,str2,indexOfCh1+1,indexOfCh2+1);
        } else if (str1.charAt(indexOfCh1)== '*' ){
            return stringCompD(str1,str2,indexOfCh1,indexOfCh2+1)
                    ||stringCompD(str1,str2,indexOfCh1+1,indexOfCh2+1)
                    || stringCompD(str1,str2,indexOfCh1+1,indexOfCh2);
        } else {
            return false;
        }
    }


    //-------------------------------------------------
    public static String stringComp(String str1 ,String str2){//91%
        char[] ch1 = str1.toCharArray();
        char[] ch2 = str2.toCharArray();
        int indexOfCh1 = 0 ;
        int length = ch2.length;
        for (int i = 0; i < length; i++) {
            if (indexOfCh1+1 == str1.length() && i+1 == str2.length()){
                return "true";
            }
            if (indexOfCh1+1 == str1.length()){
                return "false";
            }
            if (ch1[indexOfCh1] != '*' && ch1[indexOfCh1] != '?' && ch1[indexOfCh1] != ch2[i]){
                return "false";
            }
            if (ch1[indexOfCh1] == '?' || ch1[indexOfCh1] == ch2[i]){
                indexOfCh1++;
                continue;
            }

            if (indexOfCh1+1<length && i +1 < length){

                    if (ch1[indexOfCh1+1] == ch2[i+1] || ch1[indexOfCh1+1] == ch2[i] ){
                    indexOfCh1++;
                    continue;
                }
            }

        }
        return "true";
    }

    //-------------------------------------------------
    public static int countRabByMonth (int month){
        if (month == 0){
            return  0;
        }
        int f2 = 1;
        int f1 = 1;
        int f =0;
        for (int i = 2; i < month; i++) {
            f = f1 +f2 ;
            f2 =f1 ;
            f1 =f;
        }
        return f1;
    }

}
